Hardware for a local area network (LAN) service processor manages access to the physical LAN network on a particular electronic device. A corresponding LAN software driver works in conjunction with the LAN hardware to process the data stored in memory by the LAN hardware.
Both the LAN hardware and the LAN software have respective buffer indices that indicate which buffer in a ring of buffers the corresponding hardware or software will access. With normal data processing when the buffer indices are synchronized, the LAN software would receive an interrupt from the LAN hardware that a new LAN packet of data was received and ready for processing. The LAN software would check its buffer index and find the new data to process. In addition, when each of the LAN hardware and LAN software buffer indices reach the end of the ring of buffers, the indices are moved to the beginning of the ring to continue storing, accessing, and processing data.
Normally, the hardware LAN and the software LAN driver have synchronized buffer indices for storing and processing efficiency. However, the LAN hardware buffer index and the LAN software buffer index may become unsynchronized. For example, the LAN hardware on a service processor can start running before the LAN software driver is initialized. In that case, the LAN hardware could be receiving and storing LAN packets into a ring of buffers for memory. While the software LAN driver remains uninitialized, no processing of received data is done by the LAN software, and correspondingly the LAN software buffer index remains static. As a result, the hardware and the software buffer indices would be unsynchronized since the LAN hardware buffer index would be ahead of the LAN software buffer index.
In another case, the LAN hardware buffer index may advance without inputting data into a buffer. When the LAN software accesses the buffer for processing, that buffer would have been skipped by the LAN hardware without any storing of unprocessed data.
If the LAN hardware buffer index is not pointing to the same memory location as the LAN software buffer index when the LAN software receives an interrupt indicating a LAN packet containing data has been stored and is ready for processing, the LAN software will check the buffer indicated by its buffer index and discover that there is nothing new to process. In that case, the LAN software will wait without advancing its buffer index. Meanwhile, the LAN hardware will continue to receive incoming LAN packets of data and store them into succeeding buffers.
The LAN hardware and software buffer indices will continue to be unsynchronized until the LAN hardware buffer index has moved to the same location as the LAN software index. The LAN software buffer index would be synchronized with the LAN hardware buffer index until the LAN software buffer index reaches all the previously stored buffers in the ring still containing unprocessed data. At that point, the LAN software would process all the unprocessed data within a single time period, advancing the software index until reaching a buffer containing processed data. As such, the LAN software buffer index would again be out of synchronization with the LAN hardware buffer index.
Prior Art FIG. 1 is a flow diagram 100 illustrating the processing of data when the LAN hardware and software buffers are unsynchronized in one situation. Diagram 100 illustrates a ring of N buffers for storing data, including buffers 0, 1, 2, 3, on up to N. The upper portion of diagram 100 shows the flow of the LAN hardware buffer index in varying stages. The lower portion of diagram 100 shows the flow of the LAN software buffer index in the same varying stages. At stage 0, both the LAN hardware and software buffer indices are unsynchronized. The LAN hardware buffer index points at buffer 3 and the LAN software buffer index points at buffer 0. Buffers 0 and 3 contain processed data.
At stage 1, the LAN hardware receives a LAN packet. The LAN packet is stored into buffer 3 and the LAN hardware buffer index is advanced to point to buffer 4. The LAN hardware sends an interrupt to the LAN software. The LAN software checks the buffer, buffer 0, indicated by its buffer index and discovers processed data, and continues to wait. The LAN packet in buffer 3 remains unprocessed by the LAN software.
At stage 2, the LAN hardware receives another LAN packet. The LAN packet is stored into buffer 4 and the LAN hardware buffer index is advanced to point to the next buffer, buffer 5. The LAN hardware sends an interrupt to the LAN software. The LAN software checks the buffer, buffer 0, indicated by its buffer index and discovers processed data, and continues to wait. This continues buffer after buffer until the LAN hardware buffer index points to the last buffer in the ring of buffers, buffer N.
At stage 3, the LAN hardware receives another LAN packet. The LAN packet is stored into buffer N and the LAN hardware buffer index is advanced to point to buffer 0. The LAN hardware sends an interrupt to the LAN software. The LAN software checks the buffer, buffer 0, indicated by its buffer index and discovers processed data, and continues to wait.
In stage 4, the LAN hardware and software buffer indices become synchronized for a momentary period. In stage 4, the LAN hardware receives another LAN packet. The LAN packet is stored into buffer 0. The LAN hardware advances its buffer index to point to buffer 1. The LAN hardware sends an interrupt to the LAN software. The LAN software checks buffer 0, as indicated by its buffer index, and discovers unprocessed data. The LAN software processes the data in buffer 0, and advances its buffer index also to buffer 1. In addition, the LAN software checks to see if buffer 1 contains unprocessed data. If buffer 1 also contains unprocessed data, then the LAN software would process that data and continue to advance its buffer index, as discussed previously. In the example, buffer 1 contains processed data.
In stage 5, the LAN hardware and software indices remain synchronized. The LAN hardware receives another LAN packet. The LAN packet is stored into buffer 1. The LAN hardware sends an interrupt to the LAN software. The LAN hardware advances its buffer index to point to buffer 2. The LAN software checks buffer 1, as indicated by its buffer index, and discovers unprocessed data. The LAN software processes the data in buffer 1, and advances its buffer index also to buffer 2.
In stage 6, the LAN hardware and software indices become unsynchronized. The LAN hardware receives another LAN packet and stores the packet into buffer 2. The LAN hardware advances its buffer index to point to buffer 3. The LAN hardware sends an interrupt to the LAN software. The LAN software checks buffer 2, as indicated by its buffer index, and discovers unprocessed data. The LAN software processes the data in buffer 2, and advances its buffer index to buffer 3. As discussed previously, the LAN software discovers that buffer 3 contains unprocessed data and processes the data in buffer 3, continually advancing the LAN software buffer index until it processes all the previously stored LAN buffers, from buffer 3 to buffer N. At this point, the LAN software buffer index points to buffer 0 while the LAN hardware buffer index points to buffer 3. Again, the buffer indices are unsynchronized.
The problem exhibited in Prior Art FIG. 1 can be solved by reinitializing the LAN hardware and software buffer indices. However, the LAN packets already received would be lost and not get processed by the LAN software. On the other hand, continuing to let the buffer indices remain unsynchronized would be an inefficient use of processing power, since the processor would remain idle for a period, and then would have to catch up by processing all the queued buffers containing unprocessed data. Moreover, incoming data might not be stored if the LAN software is unable to clear buffer memory at a rate equal to the incoming data. This also would also result in lost data.